using System;
using UnityEngine;

namespace Yoozoo.Modules.InnerCity
{
    public class CityScaleItem : MonoBehaviour
    {
        public AnimationCurve scaleCurve;

        public float initScale;
        public float minScale;

        private Vector3 lscale = Vector3.one;

        public GameObject ground1;
        private bool groundActive1 = true;
        public GameObject ground2;
        private bool groundActive2 = true;
        
        public float groundMatPercent = 25;


        public void UpdateLOD(int lod, float lodPercent)
        {
            if (!ground1 || !ground2)
            {
                return;
            }
            
            if (lod > 0 || lodPercent > groundMatPercent)
            {
                if (!groundActive2)
                {
                    ground2.SetActive(true);
                    groundActive2 = true;
                }

                if (groundActive1)
                {
                    ground1.SetActive(false);
                    groundActive1 = false;
                }
            }
            else
            {
                if (groundActive2)
                {
                    ground2.SetActive(false);
                    groundActive2 = false;
                }

                if (!groundActive1)
                {
                    ground1.SetActive(true);
                    groundActive1 = true;
                }
            }
        }
        
//        public void SetScale(float factor)
//        {
//            float scale = scaleCurve.Evaluate(factor) * (minScale - initScale) + initScale;
//            lscale.x = scale;            
//            lscale.y = scale;            
//            lscale.z = scale;
//            transform.localScale = lscale;
//        }

    }
}